package com.fyp.client.ptma;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.ListFragment;

import com.fyp.client.ptma.adapters.CustomAdapterApplicationDetail;
import com.fyp.client.ptma.model.Application;
import com.fyp.client.ptma.model.ApplicationVersion;

public class ApplicationDetailFragment extends ListFragment
{

	private CustomAdapterApplicationDetail mAdapter;

	@Override
	public void onActivityCreated(Bundle savedInstanceState)
	{
		super.onActivityCreated(savedInstanceState);
		setEmptyText("No Version Available");

		// Create an empty adapter we will use to display the loaded data.
		mAdapter = new CustomAdapterApplicationDetail(getActivity());
		setListAdapter(mAdapter);

		// Start out with a progress indicator.
		setListShown(true);

		// Prepare the loader. Either re-connect with an existing one,
		// or start a new one.

	}

	@Override
	public void onAttach(Activity activity)
	{
		if (!(activity instanceof ApplicationDetailClickListener))
		{
			throw new ClassCastException(
					"Activity Must Implement CustomAdapterApplicationDetail");
		}

		super.onAttach(activity);
	}

	public void updateView(Application application)
	{

		mAdapter.setData(application);
		mAdapter.notifyDataSetChanged();
	}

	public static interface ApplicationDetailClickListener
	{
		public void onApplicationVersionClickListener(ApplicationVersion version);

		public void onApplicationVersionLogClickListener(
				ApplicationVersion version);
	}

}
